class Person:

    # 类属性，所有实例共享的属性
    school = "清华大学"
    instance_count = 0

    address = ""

    def __new__(cls, *args, **kwargs):
        print(
            "0.实例的创建先执行到这里，然后再去执行__init__方法 ,args=",
            args,
            "kwargs=",
            kwargs,
        )
        instance = super().__new__(cls)
        return instance
        # return cls

    # 1.类的构造函数
    def __init__(self, name, age):
        self.name = name
        self.age = age
        # self.address = "苏苑100号"
        Person.instance_count += 1

    # 2.实例方法
    def show_name(self):
        print(f"姓名：{self.name},年龄:{self.age}")

    # 3.通过classmethod装饰器定义方法为类方法，通过
    @classmethod
    def get_instance(cls):
        print(f"总共创建了{cls.instance_count}个实例")

    @staticmethod
    def say_hi():
        print("你好")


p1 = Person("jackie", 20)
p2 = Person("susan", 35)
p3 = Person("linda", 23)

# p1.address = "南京路----1001111号"
Person.address = "1001111号"

print(p1.address, "p2.address=", p2.address, "p3.address=", p3.address)

p1.address = "南京路100号"

print(p1.address, "p2.address=", p2.address, "p3.address=", p3.address)

print(dir(p1.__dict__))
